package com.fanbuchi.app.ins.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;

import de.greenrobot.event.EventBus;
import de.greenrobot.event.SubscriberExceptionEvent;

/**
 * Created by win7 on 2016/6/3.
 */
public class DaemonService extends Service {
    //

    @Override
    public void onCreate() {
        super.onCreate();
        EventBus.getDefault().register(this);
        EventBus.getDefault().post(new Living());
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().post(new Living());
        EventBus.getDefault().unregister(this);
    }

    public void onEvent(Living living){
        Log.e("onEvent","living");
        Intent service= new Intent(this,LongSocketService.class);
        startService(service);
    }

    public void onEvent(SubscriberExceptionEvent living){
        Log.e("onEvent","SubscriberExceptionEvent 11111111");
        EventBus.getDefault().post(new Living());
    }

}
